package OtherMethod;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import XmlLoader.Position;

public class PointTimeList {
	
	protected HashMap<Integer, List<PosAndID>> hashTime_Pos = null;
	
	public PointTimeList() {
		this.hashTime_Pos = new HashMap<Integer, List<PosAndID>>();
	}
	
	public void ACT001_add(int time, Position pos, int trajID, int pointID) {
		//check whether time has been added
		if(!this.hashTime_Pos.containsKey(time)) {
			List<PosAndID> addList = new ArrayList<PosAndID>();
			this.hashTime_Pos.put(time, addList);
		}
		//add point to specific hash
		List<PosAndID> getList = this.hashTime_Pos.get(time);
		PosAndID posAndID = new PosAndID(pos, trajID, pointID);
		getList.add(posAndID);
	}
	
	public void ACT002_showHashIndexResult() {
		int indexTime = 0, indexPoint = 0;
		Integer[] timeKeySet = this.hashTime_Pos.keySet().toArray(new Integer[0]);
		while(indexTime < this.hashTime_Pos.size()) {
			List<PosAndID> listPos = this.hashTime_Pos.get(timeKeySet[indexTime]);
			System.out.println("Time = " + timeKeySet[indexTime] + "\n");
			indexPoint = 0;
			while(indexPoint < listPos.size()) {
				Position pos = listPos.get(indexPoint).pos;
				System.out.println("< " + pos.x + " , " + pos.y + " >\n");
				indexPoint = indexPoint + 1;
			}
			indexTime = indexTime + 1;
		}
	}
	
	public HashMap<Integer, List<PosAndID>> GET001_hashTime_Pos() {
		return this.hashTime_Pos;
	}
}
